import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

import '../components/PageWrap.dart';

// Tab 页面
class Page extends StatefulWidget {
  const Page({Key? key, required this.text}) : super(key: key);

  final String text;

  @override
  _PageState createState() => _PageState();
}

class _PageState extends State<Page> {
  @override
  Widget build(BuildContext context) {
    print("build ${widget.text}");
    return Center(child: Text("${widget.text}", textScaleFactor: 5));
  }
}

class PageViewLn extends StatefulWidget {
  const PageViewLn({super.key});

  @override
  State<PageViewLn> createState() => _PageViewLnState();
}

class _PageViewLnState extends State<PageViewLn> {
  @override
  Widget build(BuildContext context) {
    var children = <Widget>[];
    // 生成 6 个 Tab 页
    for (int i = 0; i < 6; ++i) {
      children.add(Page(text: '$i'));
    }

    return Scaffold(
      appBar: AppBar(
        title: Text(
          "PageView", // 设置标题文本
          style: TextStyle(
            color: Colors.white, // 设置标题字体颜色
          ),
        ),
        iconTheme: IconThemeData(
          color: Colors.white, // 设置返回图标颜色
        ),
        backgroundColor: Colors.deepPurple, /// 设置AppBar背景颜色
      ),
      body:    PageView(
        // scrollDirection: Axis.vertical, // 滑动方向为垂直方向
        children: children,
      ) ,
    );


  }
}
